﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataMode;
using IDAL;

namespace DAL
{
    public class PictureDAL : IDAL.PictureIDAL
    {
        DataMode.DataModeDataContext ctx = new DataMode.DataModeDataContext();

        public void addNewPicture(DateTime addDate, string discription, string picture_path)
        {
            picture pic = new picture();
            pic.picture_date = addDate;
            pic.picture_description = discription;
            pic.picture_path = picture_path;
            ctx.picture.InsertOnSubmit(pic);
            ctx.SubmitChanges();
        }

        public void deletePicture(int pictureId)
        {
            var picture = from pic in ctx.picture
                          where pic.picture_id == pictureId
                          select pic;
            ctx.picture.DeleteAllOnSubmit(picture);
            ctx.SubmitChanges();
        }

        public void modifyPicture(int pictureId, DateTime addDate, string discription)
        {

        }

        public IQueryable selectPicture(int pictureId)
        {
            IQueryable<picture> npicture = from pic in ctx.picture
                                           where pic.picture_id == pictureId
                                           select pic;
            return npicture;
        }
    }
}